package com.ly.base;

import org.junit.Before;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;

import com.ly.erms.ErmsApplication;

/**
 * 基础测试类
 * 
 * @author liuyang
 * @date 2017年12月29日
 */
@RunWith(SpringRunner.class)
@SpringBootTest(classes = ErmsApplication.class)
@WebAppConfiguration
// @Transactional //打开的话 测试数据会自动回滚
public class BaseJunit {
	@Autowired
	WebApplicationContext webApplicationContext;

	protected MockMvc mockMvc;

	protected MockHttpServletRequest request;

	protected MockHttpServletResponse response;

	@Before
	public void setup() {
		mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
		request = new MockHttpServletRequest();
		request.setCharacterEncoding("UTF-8");
		response = new MockHttpServletResponse();
	}
}
